package NiuKe;

import java.util.*;

/**
 * 明明生成了
 * N个1到500之间的随机整数。请你删去其中重复的数字，即相同的数字只保留一个，
 * 把其余相同的数去掉，然后再把这些数从小到大排序，按照排好的顺序输出。
 * 数据范围：1≤n≤1000  ，输入的数字大小满足1≤val≤500
 * count = 0
 * 5 0 0 0
 */
public class Mingming {
    public static void main(String[] args) {
        int count = 0;
        Scanner in = new Scanner(System.in);
        int len = in.nextInt();
        if(len < 1 || len > 1000){
            System.out.println("请输入正确列表长度范围 1≤len ≤1000");
        }
        int[] result = new int[len];
        // 注意 hasNext 和 hasNextLine 的区别
        while (len > 0) { // 注意 while 处理多个 case
            int a = in.nextInt();
            len--;
            if (a < 1 || a > 500) {
                break;
            }
            int address = count;
            if (!doubleZhiZhen(result, count-1, a)) {
                for (int i = count - 1; i >= 0; i--) {
                    if (result[i] > a) {
                        result[i + 1] = result[i];
                        address--;
                    } else {
                        break;
                    }
                }
                result[address] = a;
                count++;
            }
        }

        for (int i = 0; i < count; i++) {
            System.out.println(result[i]);
        }
    }

    public static boolean doubleZhiZhen(int[] list, int count, int search) {
        int left = 0;
        int right = count;
        while (right >= left) {
            if (list[left] == search || list[right] == search) {
                return true;
            }
            right--;
            left++;
        }
        return false;
    }
}
